﻿using System;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using AnyOffice.Model;


namespace AnyOffice.general.system.attend
{
    public partial class holiday : ModulePage 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                this.txtBeginDate.Value = this.txtEndDate.Value = DateTime.Now.ToString("d");
                DataTable table = new AttendHolidayDao().SelectAll(base.Conn);
                if (table.Rows.Count > 0)
                {
                    this.rptHoliday.DataSource = table;
                    this.rptHoliday.DataBind();
                }
                else
                {
                    this.litMessage.Text = base.ShowMessage("尚未添加日期");
                }
            }
            if (this.Page.IsPostBack)
            {
                AttendHolidayDao dao2 = new AttendHolidayDao();
                AttendHolidayData data = new AttendHolidayData();
                data.BeginDate = Convert.ToDateTime(this.txtBeginDate.Value);
                data.EndDate = Convert.ToDateTime(this.txtEndDate.Value);
                dao2.Insert(base.Conn, data);
                DataTable table2 = dao2.SelectAll(base.Conn);
                this.rptHoliday.DataSource = table2;
                this.rptHoliday.DataBind();
                this.litMessage.Text = "";
            }
        } 

    }
}
